package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.pro.TaskList;
import com.qidianit.mes.pro.mapper.TaskListMapper;
import com.qidianit.mes.pro.service.TaskListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: shanzhe
 * @Date: 2025/9/24 - 18:55
 */
@Service
public class TaskListServiceImpl implements TaskListService {
    @Autowired
    private TaskListMapper taskListMapper;
    @Override
    public PageInfo<TaskList> selectTaskPage(Integer pageNum, Integer pageSize, Long productionOrderId, Long processId,Integer workflowId) {
       PageHelper.startPage(pageNum, pageSize);
        List<TaskList> taskLists = taskListMapper.selectTaskPage(productionOrderId, processId,workflowId);
        PageInfo<TaskList> pageInfo = new PageInfo<>(taskLists);
        return pageInfo;
    }

    @Override
    public int addTaskListByProductionOrderIdAndProcessId(TaskList taskList) {
        return taskListMapper.addTaskListByProductionOrderIdAndProcessId(taskList);
    }

    @Override
    public int updateTaskCodeById(TaskList taskList) {
        return taskListMapper.updateTaskCodeById(taskList);
    }

    @Override
    public int deleteTaskListById(Long taskListId) {
        return taskListMapper.deleteTaskListById(taskListId);
    }

    @Override
    public int batchDeleteTaskListByIds(List<Long> ids) {
        Integer sum = 0;
        for (Long id : ids) {
           sum+= taskListMapper.deleteTaskListById(id);
        }
        if(sum==ids.size()){
            return 1;
        }
        return 0;
    }


}
